<template>
    <div class="box">
        <button @click="getLoveTalk"> 获取一个土味情话</button>
        <ul>
            <li v-for="item in talkStore.talks" :key="item.id">{{ item.title }}</li>
        </ul>
    </div>
</template>

<script setup lang="ts" name="LoveTalk">
import {useTalksStore} from '@/store/loveTalk'

const talkStore = useTalksStore()

talkStore.$subscribe((mutate,state)=>{
    localStorage.setItem('talks',JSON.stringify(state.talks))
})

function getLoveTalk() {
    talkStore.getTalk()
}
</script>

<style scoped>
.box {
    background-color: skyblue;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 0 10px;
}
</style>